<template>
	<view class="container">
		<view class="intro">
			<image src="/static/images/index/wm.png"></image>
			<view class="tips">
				洛师订餐
				<br>
				无接触，自助取餐订餐
			</view>
			<view class="tips tipsbot">
				<input type="text" v-model="phone" placeholder="请输入手机号" />
			</view>
			<view class="tips tipsbot">
				<input type="password" v-model="password" placeholder="请输入密码" />
			</view>
		</view>
		<view class="bottom">
				<button type="primary" size="default" class="login-btn" @tap="login">
					登录
				</button>
				<view class="reg" @click="open_reg">
					注册
				</view>
		</view>
	</view>
</template>

<script>
	import Member from '@/api/member'
	import {mapMutations} from 'vuex'
	
	import vlogin from '../../utils/controller/login.js'
	
	export default {
		data() {
			return {
				phone:'13112345678',
				password:'123456',
				success:new vlogin()
			}
		},
		methods: {
			...mapMutations(['SET_MEMBER']),
			async login() {
				const {vphone,vpassword,vlogin} = this.success
				const phone = await vphone(this.phone)
				if(!phone) return uni.showToast({title:'请输入正确手机号',icon:'none'})
				const password = await vpassword(this.password)
				if(!password) return uni.showToast({title:'请输入密码',icon:'none'})
				const result = await vlogin({mobile:this.phone,passWord:this.password})
				console.log(result)
				if(result.data.code == 0){
					uni.showToast({
						title:result.data.msg,
						icon:'none'
					})
					this.SET_MEMBER(result.data.data)
					setTimeout(()=>{
						uni.reLaunch({
							url:'../index/index'
						})
					},500)
					
				}
			},
			open_reg(){
				uni.navigateTo({
					url:'../reg/reg'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.tipsbot{
		border-radius: 99px;
		border: solid 1px #E2E2E2;
		padding: 16rpx 100rpx;
	}
	.reg{
		color: #5A5B5C;
		text-align: center;
		font-size: 28rpx;
		padding: 60rpx 30rpx;
	}
	.intro {
		width: 100%;
		height: 60vh;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: space-evenly;
		font-size: $font-size-base;
		color: $text-color-assist;
		
		image {
			border-radius: 50%;
			width: 165rpx;
			height: 165rpx;
		}
		
		.tips {
			line-height: 72rpx;
			text-align: center;
		}
		.tips input{
			font-size: 28rpx;
		}
	}
	
	.bottom {
		// height: 40vh;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		padding: 0 40rpx;
		
		.login-btn {
			width: 100%;
			border-radius: 50rem !important;
			display: flex;
			align-items: center;
			justify-content: center;
			padding: 10rpx 0;
			
			image {
				width: 36rpx;
				height: 30rpx;
				margin-right: 10rpx;
			}
		}
		
		.row {
			.grid {
				width: 20%;
				image {
					width: 60rpx;
					height: 60rpx;
					margin-bottom: 10rpx;
				}
			}
		}
	}
</style>
